@extends('admin.layouts.base')

@section('title','发布文章')

@section('css')
    <link rel="stylesheet" href="{{ asset('bootstrapvalidator/dist/css/bootstrapValidator.min.css') }}" >
    <link rel="stylesheet" href="{{ asset('editor.md/css/editormd.min.css') }}">
    <style>
        .title_left{
            text-align: left !important;
            margin-bottom: 5px !important;
        }
    </style>
@endsection

@section('pageHeader','控制面板')

@section('pageDesc','DashBoard')

@section('content')
    <div class="main animsition">
        <div class="container-fluid">

            <div class="row">
                <div class="">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h3 class="panel-title">发布文章</h3>
                        </div>
                        <div class="panel-body">

                            @include('admin.partials.errors')
                            @include('admin.partials.success')

                            <form class="form-horizontal" id="article-form" role="form" method="POST" action="/admin/article">
                                <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                @include('admin.article._form')

                                <div class="form-group">
                                    <div class="col-md-7 col-md-offset-3">
                                        <button type="submit" class="btn btn-primary btn-md">
                                            <i class="fa fa-plus-circle"></i>
                                            发布
                                        </button>
                                    </div>
                                </div>

                            </form>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@stop

@section('js')
    <script src="{{ asset('editor.md/editormd.min.js') }}"></script>
    <script src="{{ asset('bootstrapvalidator/dist/js/bootstrapValidator.min.js') }}" ></script>
    <script>

        var editor = editormd("editormd", {
            path        : "{{ asset('/editor.md/lib/') }}/",
            height  : 500,
            syncScrolling : "single",
            toolbarAutoFixed: false,
            saveHTMLToTextarea : false
        });
        /* 文章操作验证 */
        $("#article-form").bootstrapValidator({
            live: 'disables',
            message: "This Values is not valid",
            feedbackIcons: {
                valid: 'glyphicon ',
                invalid: 'glyphicon ',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields : {
                title : {
                    validators : {
                        notEmpty : {
                            message : "文章标题不能为空"
                        }
                    }
                },
                cate_id : {
                    validators : {
                        notEmpty : {
                            message : "请选择文章分类"
                        }
                    }
                }
            }
        }).on('success.form.bv', function(e) {
            var html = editor.getPreviewedHTML();
            $("#article-form textarea[name='html_content']").val(html);
        });
    </script>
@endsection